/*
 * PlantView.cpp
 *
 *  Created on: 31/05/2014
 *      Author: javier
 */

#include "PlantView.h"

PlantView::PlantView(SDLWindow* window, SDL_Texture* texture,
		Positionable* object) :
		cycler(8) {
	this->window = window;
	this->texture = texture;
	this->object = object;
	geometry.first = object->getX();
	geometry.second = object->getY();
	base = 0;
	int iW = 25;
	int iH = 30;
	for (int i = 0; i < 8; ++i) {
		clips[i].x = i * iW;
		clips[i].y = 0;
		clips[i].w = iW;
		clips[i].h = iH;
	}
	useClip = 0;
}

void PlantView::render(Camera& cam) {
	SDL_Rect render = cam.getOffsetFromModel(geometry);
	window->renderTexture(texture, &render, &clips[useClip]);
}

void PlantView::update() {
	useClip = cycler.next();

}

PlantView::~PlantView() {
	// TODO Auto-generated destructor stub
}

